package com.gitee.zycra.file.utils;

import java.io.File;

/**
 * Encrypt or decrypt util of AES.
 *
 * @author zycra
 * @since 1.0.0
 */
public final class AESUtil extends SymmetricEncryptUtil {

    private AESUtil() {
    }

    /**
     * AES encrypt the content with given password.
     *
     * @param content  the content to encrypt.
     * @param password the password for encrypt.
     * @return encrypt result.
     */
    public static String encrypt(String content, String password) {
        return encrypt(content, password, SymmetricEncryptUtil.AES_LABEL);
    }

    /**
     * AES decrypt the content with given password.
     *
     * @param content  the content to decrypt.
     * @param password the password for decrypt.
     * @return decrypt result.
     */
    public static String decrypt(String content, String password) {
        return decrypt(content, password, SymmetricEncryptUtil.AES_LABEL);
    }

    /**
     * AES encrypt file with given password.
     *
     * @param originFile  the origin file to encrypt.
     * @param encryptFile the target path to store encrypt file.
     * @param password    the password for encrypt.
     * @return whether successful.
     * @since 1.0.0
     */
    public static boolean encrypt(File originFile, File encryptFile, String password) {
        return encrypt(originFile, encryptFile, password, SymmetricEncryptUtil.AES_LABEL);
    }

    /**
     * AES decrypt file with given password.
     *
     * @param originFile  the origin file to decrypt.
     * @param decryptFile the target path to store decrypt file.
     * @param password    the password for decrypt.
     * @return whether successful.
     * @since 1.0.0
     */
    public static boolean decrypt(File originFile, File decryptFile, String password) {
        return decrypt(originFile, decryptFile, password, SymmetricEncryptUtil.AES_LABEL);
    }

    /**
     * Generate an AES key.
     *
     * @return AES key.
     * @since 1.0.0
     */
    public static String generateKey() {
        return generateKey(SymmetricEncryptUtil.AES_LABEL);
    }
}
